package co.baiku.boot.service;

import co.baiku.boot.core.orm.dto.AuthDetailDto;
import co.baiku.boot.core.orm.dto.UserDetailDto;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 登录处理
 */
@Component(value = "CustomUserDetailsService")
public class CustomUserDetailsServiceImpl implements UserDetailsService {

    @Override
    public UserDetailDto loadUserByUsername(String name) throws UsernameNotFoundException {
        List<AuthDetailDto> roles = new ArrayList<>();
        AuthDetailDto roleDetailDto = new AuthDetailDto("Admin");
        roles.add(roleDetailDto);
        UserDetailDto userDetail = new UserDetailDto(1L, name, roles);
        userDetail.setPassword("$2a$10$j98muj3FO7u7kJXA6MQD8Or8riNABLBgrKzv1C1RaC7lgZioReIPy");
        return userDetail;
    }
}
